<?php
/**
 * aheadWorks Co.
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the EULA
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://ecommerce.aheadworks.com/LICENSE-M1.txt
 *
 * @category   AW
 * @package    AW_Mobile
 * @copyright  Copyright (c) 2010-2011 aheadWorks Co. (http://www.aheadworks.com)
 * @license    http://ecommerce.aheadworks.com/LICENSE-M1.txt
 */
?>
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<?php $product=$_product=$this->getProduct() ?>
<div class="product-info-box">
    <div class="product-essential">
        <div class="product-img-box">
			<a href="<?php echo $product->getProductUrl() ?>" title="<?php echo $this->htmlEscape($product->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(138) ?>" width="138" height="138" alt="<?php echo $this->htmlEscape($product->getName()) ?>" /></a>
			<div class="product-shop">
				<?php $simplePricesTax = ($this->helper('tax')->displayPriceIncludingTax() || $this->helper('tax')->displayBothPrices()); ?>
				<?php $_minimalPriceValue = $_product->getMinimalPrice() ?>
				<?php $_minimalPrice = $this->helper('tax')->getPrice($product, $_minimalPriceValue, $simplePricesTax) ?>
				<a href="<?php echo $product->getProductUrl() ?>" title="<?php echo $this->helper('awmobile')->stripTags($product->getName(), null, true) ?>"><?php echo $this->helper('catalog/output')->productAttribute($product, $product->getName(), 'name') ?></a>
				<?php
				if ($product->getTypeId() == 'bundle'){
					list($_minimalPrice, $_maximalPrice) = $product->getPriceModel()->getPrices($product);
					$_price = $_minimalPrice;
				} elseif ($product->getTypeId() == 'grouped') {     
					$_exclTax = $this->helper('tax')->getPrice($product, $_minimalPriceValue, $includingTax = null);
					$_inclTax = $this->helper('tax')->getPrice($product, $_minimalPriceValue, $includingTax = true);                        
					$_price = $_inclTax;
					if (!$this->helper('tax')->displayPriceIncludingTax()) {
						$_price = $_exclTax;
					}                        
				} else {
					$_regularPrice = $product->getPrice();
					$_price = $product->getFinalPrice();
				} ?>
				<div class="price-block">
					<?php if($_regularPrice!=$_price): ?>
					<span class="product-regular-price"><?php echo Mage::app()->getStore()->convertPrice( $_regularPrice, true ); ?></span>
					<?php endif; ?>
					<span class="product-price"><?php echo Mage::app()->getStore()->convertPrice( $_price, true ); ?></span>
				</div>
		        <p><a href="<?php echo $product->getProductUrl() ?>">&laquo; <?php echo $this->__('Back to Main Product Info') ?></a></p>
			</div>
			<div class="clear"></div>
        </div>

        <div class="product-shop">
        <?php echo $this->getChildHtml('rating') ?>
        <?php if( $reviewCount ): ?>
            <a href="#customer-reviews" class="no-wrap"><small><?php echo $this->__('%s Review(s)', $reviewCount) ?></small></a>
        <?php endif; ?>

        <form action="<?php echo $this->getUrl('checkout/cart/add') ?>" method="post" id="product_addtocart_form">
        <fieldset>
        <input type="hidden" name="product" value="<?php echo $product->getId() ?>" />
        </fieldset>

        <?php if($product->isSuperConfig()): ?>
        <?php echo $this->getChildHtml('super_config') ?>
        <?php endif; ?>

        <?php if($product->isGrouped()): ?>
            <?php echo $this->getChildHtml('super_group') ?>
        <?php endif; ?>

        <?php if(!$product->isGrouped()): ?>
            <?php if($product->isSaleable()): ?>
            <p><small><?php echo $this->__('Availability: In stock.') ?></small></p>
            <?php else: ?>
            <p><small><?php echo $this->__('Availability: Out of stock.') ?></small><br /></p>
            <?php endif; ?>
			<?php echo $this->getChildHtml('prices'); ?>
			<?php if (!$this->hasOptions()):?>
				<?php if($product->isSaleable()): ?>
					<?php echo $this->getChildHtml('addtocart') ?>
				<?php endif; ?>
			<?php endif; ?>
			<?php echo $this->getChildHtml('paypal_wrapper'); ?>
        <?php else: ?>
            <button class="form-button" onclick="productAddToCartForm.submit()"><span><?php echo $this->__('Add to Cart') ?></span></button> <strong><?php echo $this->__('OR') ?></strong>

        <?php if ($this->helper('wishlist')->isAllow()) : ?>
            &nbsp;&nbsp;<a href="<?php echo $wishlistLink ?>"><?php echo $this->__('Add to Wishlist') ?></a>
        <?php endif; ?>

        <?php if($_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($product)): ?>
            <span class="pipe">|</span><a href="<?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a>
        <?php endif; ?>

        <?php endif; ?>
        </form>
        <script type="text/javascript">
            var productAddToCartForm = new VarienForm('product_addtocart_form');
            productAddToCartForm.submit = function() {
                if(this.validator.validate()) {
                    this.form.submit();
                }
            }.bind(productAddToCartForm);
        </script>
        <div class="clear"></div>
        <div class="divider"></div>


        </div>
        </div>

        <div class="product-collateral">
		<?php echo $this->getChildHtml('reviewForm') ?>
		</div>
</div>
